// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import './assets/js/adapter'
import 'element-ui/lib/theme-chalk/index.css'; // 默认主题
import ElementUI from 'element-ui';

Vue.config.productionTip = false

import axios from 'axios'
Vue.prototype.$axios = axios
const echarts = require('echarts')
Vue.prototype.$echarts = echarts
Vue.use(ElementUI);
Vue.prototype.$eventBus = new Vue();

router.beforeEach((to, from, next) => {
  if (to.path === '/') {
    let id = localStorage.getItem('ID');
    if (id) {
      next();
    } else {
      console.log(to.meta.keepAlive)
      next('/login');
    }
  } else {
    next();
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
